<!-- 企业信息详情 -->
<template>
  <div class="detail-index-content">
    <HeadLabel title="企业信息详情" routeName="enterpriseInforInquiry" />
    <div class="page-main-content">
      <div class="page-main-content-head">
        <h2>企业名称</h2>
        <BtnText type="primary" @BtnClick="modelValueHistory = true">变更历史记录</BtnText>
      </div>
      <h3>企业基本信息</h3>
      <div class="page-main-form-box">
        <Row>
          <Col span="8">
            <MainFormItem title="企业名称">{{ formData.companyName}}</MainFormItem>
          </Col>
          <Col span="8">
            <MainFormItem title="上级组织">{{ formData.parentName}}</MainFormItem>
          </Col>
          <Col span="8">
            <MainFormItem title="证件类型">{{ formData.companyCardTypeName}}</MainFormItem>
          </Col>
          <Col span="8">
            <MainFormItem title="证件号码">{{ formData.companyCardNumber}}</MainFormItem>
          </Col>
          <Col span="8">
            <MainFormItem title="注册地址">{{ formData.companyAddress}}</MainFormItem>
          </Col>
          <Col span="8">
            <MainFormItem title="证件照片">
              <ViewImg isPreview isViewBtn isIcon errorMsg="证件照片" :fileList="formData.companyIdFiles"></ViewImg>
            </MainFormItem>
          </Col>
          <Col span="24">
            <MainFormItem title="业务范围">{{ formData.businessRange}}</MainFormItem>
          </Col>
        </Row>
      </div>
      <Divider />
      <h3>企业服务能力</h3>
      <div class="page-main-form-box">
        <Row>
          <Col span="24">
            <MainFormItem title="服务地区">{{ convertStr(formData.serviceArea, "provinceName", "cityName")}}</MainFormItem>
          </Col>
          <Col span="24">
            <MainFormItem title="产业标记">{{ convertStr(formData.serviceType, "serviceTypeName")}}</MainFormItem>
          </Col>
        </Row>
      </div>
      <Divider />
      <h3>企业收益规则</h3>
      <div class="page-main-form-box">
        <Row>
          <Col span="12">
            <MainFormItem title="规则说明">
              <!-- {{ formData.companyRuleFiles }} -->
              <template v-if="formData.companyRuleFiles && formData.companyRuleFiles.length > 0">
                <ViewImg isPreview errorMsg="规则说明" :fileList="formData.companyRuleFiles"></ViewImg>
              </template>
              <template v-else> 暂无附件 </template>
            </MainFormItem>
          </Col>
          <Col span="12">
            <MainFormItem title="收益规则" >{{ formData.companyDivideIntoRuleValue }}%</MainFormItem>
          </Col>
        </Row>
      </div>
      <Divider />
      <h3>企业资质</h3>
      <div class="page-main-form-box page-main-form-table">
        <Table :columns="columns" :data="formData.companyAptitudeFiles">
          <template slot-scope="{ row }" slot="file">
            <ViewImg isPreview isViewBtn isIcon errorMsg="资质照片" :fileList="row.files"></ViewImg>
          </template>
        </Table>
      </div>
      <Divider />
      <h3>备案项目</h3>
      <div class="page-main-form-box page-main-form-table">
        <Table :columns="columnsRecord" :data="formData.busiInfoList">
          <template slot-scope="{ row }" slot="rate">
            <div class="repetition-rate">
              <span>{{ row.repetitionRate }}%</span>
              <ViewImg :isImg="false"></ViewImg>
            </div>
          </template>
        </Table>
      </div>
    </div>
    <HistoryChange v-model="modelValueHistory" :companyId="formData.companyId"/>
  </div>
</template>

<script type="text/javascript">
import {
  GetCompanyDetail, //查询企业信息列表
} from "@/api/enterpriseInforManage.js";

import { returnStr } from "@/libs/util.js";
import HistoryChange from "@/pages/components/historyChange";

export default {
  name: "enterpriseInforInquiry",
  components: { HistoryChange },
  data() {
    return {
      formData: {
        auditStatus: "",
        auditStatusName: "",
        baseStatus: "",
        baseStatusName: "",
        businessLicenseImages: "",
        city: "",
        companyAddress: "",
        companyCardNumber: "",
        companyCardTypeName: "",
        companyCnSimpleName: "",
        companyCode: "",
        companyEnSimpleName: "",
        companyId: "",
        companyIdFiles: [],
        companyItems: [],
        companyLevel: "",
        companyLevelName: "",
        companyName: "",
        companyRuleFiles: [],
        busiInfoList: [], // 备案信息
        contactMobile: "",
        contactPerson: "",
        createDateTime: "",
        createUserName: "",
        district: "",
        isDel: false,
        logoUrl: "",
        parentId: "",
        province: "",
        rootId: "",
        ruleStatus: "",
        ruleStatusName: "",
        serviceArea: [],
        serviceType: [],
        companyAptitudeFiles: [],
        status: "",
        statusName: "",
        street: "",
        updateDateTime: "",
        updateUserName: "",
      },
      columns: [
        {
          title: "资质名称",
          key: "companyAptitudeName",
        },
        {
          title: "等级",
          key: "lv",
        },
        {
          title: "资质附件",
          slot: "file",
        },
        {
          title: "有效期截止时间",
          key: "validEndDate",
        },
      ],
      columnsRecord: [
        {
          title: "项目名称",
          key: "projectName",
        },
        {
          title: "重复率",
          slot: "rate",
        },
        {
          title: "业主方",
          key: "ownerCompanyName",
        },
        {
          title: "施工方",
          key: "constructionName",
        },
        {
          title: "项目地址",
          key: "projectAddressName",
        },
        {
          title: "预计产值规模(万元)",
          key: "outputScale",
        },
        {
          title: "发布时间",
          key: "createDateTime",
        },
      ],
      modelValueHistory: false,
      companyId: "",
    };
  },
  methods: {
    // 获取企业信息详情
    async getCompanyDetailData(companyId) {
      let params = {
        companyId,
      };
      let data = await GetCompanyDetail(params);
      console.log(data, "data");
      this.formData = data;
    },
    // 变更记录
    changeLog() {
      let { companyId } = this.$route.query;
      this.$router.push({
        path: "/changeRecord",
        query: {
          companyId,
          changeType: 0,
        },
      });
    },
    // 查看详情
    viewDetail(row) {},
    // 预览规则图片
    viewRuleFiles(item) {
      console.log(item, "item");
    },
    convertStr(data, key, keyTo) {
      return returnStr(data, key, keyTo);
    },
  },
  created() {
    let { query } = this.$route;
    this.getCompanyDetailData(query.companyId);
  },
};
</script>

<style lang="less" scoped>
.page-main-content {
  padding: 20px;
  background: #fff;
  border-radius: 6px;
}

.page-main-content-anduit {
  padding: 20px;
  border-radius: 8px;
  background: #fff;
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
}
</style>
